//1 创建http.Server实例
const http = require('http');
const server = http.createServer((req, res) => {
    req.on('data', (chunk) => {
        console.log(`Received: ${decodeURI(chunk)}`);
    });
    //2 处理请求
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/plain');
    res.end('Hello, World!\n');
});
//3 监听端口
server.listen(3000, () => {
    console.log('Server running at http://localhost:3000/');
});                 